// 文件管理接口

import { http } from "@/utils/http";

type Workspace = {
    success: boolean;
    data: {
          name: string;     // 文件名
          isDir: boolean;    // 是否是目录,
          path: string;     // 路径
          mtime: string,    // 修改时间
      }[];
    msg: string;
};

type FieldList = {
  success: boolean;
  data: string[];
  msg: string;
};

// 获取某个目录的一级目录
// path: 目录路径
export function IQueryWorkspace(path: string): Promise<Workspace>
{
    return http.post<Workspace>(
      "/api/fileMgr/queryWorkspace",
      {
        "path": path
      }
    );
};

// 读取指定文件的表头
// filePath: 文件路径
export function IGetFileFieldList(filePath: string): Promise<FieldList>
{
  return http.post<FieldList>(
    "/api/fileMgr/readFileFieldList",
    {
      "filePath": filePath,
    }
  )
}
